package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {


    List<Emp> selectPage(String name, Integer gender, LocalDate begin, LocalDate end, int index, Integer pageSize);

    Long selectCount(String name, Integer gender, LocalDate begin, LocalDate end);

    Page<Emp> selectList(String name, Integer gender, LocalDate begin, LocalDate end);

    /**
     * 批量删除
     *
     * @param ids
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 新增员工
     *
     * @param emp
     */
    void insert(Emp emp);

    /**
     * 根据ID查询信息
     *
     * @param id
     * @return
     */
    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    void updateById(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp selectByUsernameAndPassword(String username, String password);

    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);
}
